package com.wangzhen.spring.resource;

import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;

import java.io.IOException;

/**
 * 演示：1、ClassPathResource 读取classpath下的properties文件内容
 *      2、FileSystemResource 读取指定位置的文件内容
 *
 */
public class ReadResourceDemo {

    public static void main(String[] args) throws IOException {
        ClassPathResource resource = new ClassPathResource("META-INF/addr.properties");
        System.out.println(IOUtils.readLines(resource.getInputStream(), "UTF-8"));

        FileSystemResource fileSystemResource = new FileSystemResource("/Users/wangzhen/Downloads/codebasespring/spring-resource/src/main/resources/META-INF/addr.properties");
        System.out.println(IOUtils.readLines(resource.getInputStream(), "UTF-8"));

    }
}
